package com.ophiux.utils.common;

/**
 * 隐藏信息工具类
 * @author chenh
 *
 */
public class HidenUtil {

	/**
	 * 姓名隐藏姓氏，文字类
	 * @return
	 */
	public static  String hideName(String name) {
		try {
			if(StringUtil.isEmpty(name)) return "";
			name = "*"+ name.substring(1);
			return name;
		} catch (Exception e) {
			e.printStackTrace();
			return name;
		}
	}
	
	//隐藏数字类   身份证，电话号码   
	public static  String hideIdNo(String idCard) {
		try {
			String newCard = "";
		    if(idCard != null){
		        if(idCard.length() == 18){
		            newCard = idCard.substring(0, 6)+ "********"+idCard.substring(14, 18);
		        }else if(idCard.length() == 15){
		            newCard = idCard.substring(0, 6)+ "******"+idCard.substring(12, 15);
		        }
		    }
		    return newCard;
		} catch (Exception e) {
			e.printStackTrace();
			return idCard;
		}
	}
	
	public static void main(String[] args) {
		System.out.println(hideIdNo("500241199311172414"));
	}
	
}
